<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script src="../../js/jQuery/jquery-1.8.3.min.js"></script>
	<script src="../../js/jQuery/jquery.form.js"></script>
	<script type="text/javascript">
	   function importData() {
		   var code = request("code");
		   $("#code").val(code);
		   if($("#fileName").val() == ''){
			   top.isc.showMessage("请选择导入的文件", top.isc.OBMessageBar.TYPE_ERROR);
			   return;
		   }
		   var options = {
				url: top.OB.Application.contextUrl+"./org.openbravo.client.kernel?_action=com.basis.handler.DataImportHandler&code=" + code,
				type: 'POST',
				dataType:'json',
				data:{},
				async: false,
				success: function(data){
					if(data.result){
						top.OB.MyActiveViewRefresh();
						top.isc.showMessage(data.msg, top.isc.OBMessageBar.TYPE_SUCCESS);
						top.OB.Layout.ClassicOBCompatibility.Popup.close("import_Data_" + code);
					}else{
						top.isc.showMessage(data.msg, top.isc.OBMessageBar.TYPE_ERROR);
						//top.OB.Layout.ClassicOBCompatibility.Popup.close("import_Data_" + code);
					}
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					top.isc.showMessage("上传失败", top.isc.OBMessageBar.TYPE_ERROR);
				}
			};
			$("#importFile").ajaxSubmit(options);
			
	   }
	   function request(name) {
		   var url = window.location.href;
		   var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
		   var url_paraObj = {}
		   for (var i = 0; i < paraString.length; i++) {
			   var index = paraString[i].indexOf("=");
			   try {
				   url_paraObj[paraString[i].substring(0, index)] = decodeURI(paraString[i].substring(index + 1));
			   } catch (e) {
				   url_paraObj[paraString[i].substring(0, index)] = paraString[i].substring(index + 1);
			   }
		   }
		   return url_paraObj[name];
	   }
	</script>
</head>
<body style="margin: 35px 0;" >
	<form name="importFile" id="importFile" method="post" enctype="multipart/form-data" align="center">
		<input type="hidden" name="code" id="code"/>
		<input type="file" name="fileName" id="fileName" />
		<input type="button" value="导入" onclick="importData()"/>
	</form>
</body>
</html> 
